package com.jzx.provider.cv.repository;

import com.jzx.provider.cv.dto.command.EducationInfoCommand;
import com.jzx.provider.cv.model.CurrentInfo;
import com.jzx.provider.cv.model.EducationInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author daihuihui
 * @date 2019/2/5
 */
public interface EducationInfoRepository extends JpaRepository<EducationInfo, Integer> {
    /**
     * 根据简历id 获取教育信息
     *
     * @param cvId 简历id
     * @return 教育信息列表
     */
    List<EducationInfo> findByCvId(Long cvId);

    @Modifying
    @Query(nativeQuery = true, value = "update t_education_info set " +
            "start_date=:#{#educationInfo.startDate},end_date=:#{#educationInfo.endDate}," +
            "school=:#{#educationInfo.school},major=:#{#educationInfo.major}," +
            "education=:#{#educationInfo.education},first_or_not=:#{#educationInfo.firstOrNot},is_key_school=:#{#educationInfo.isKeySchool}," +
            "is_recruitment=:#{#educationInfo.isRecruitment},update_time=:#{#educationInfo.updateTime} where id=:#{#educationInfo.id}")
    void updateCvEducationInfo(EducationInfo educationInfo);
}
